#! /bin/bash

set -e
set -x
set -o pipefail

BUILD=@BUILDDIR@
SRC=@SRCDIR@
SCRIPT=$1

# Path to data
D=$BUILD/tests/data
PATH=$BUILD:$BUILD/tests:$SRC/tests:$PATH
# Name
N=$(basename $1 .sh)
# Working directory
WORKDIR=tests/$N
mkdir -p $WORKDIR

# Read script in fd 3 so that it is availabe after changing directory
# (path to SCRIPT may not be absolute).
exec 3<$SCRIPT
cd $WORKDIR
source /dev/fd/3
